package com.mz.auth.mapper;

import com.mz.auth.entity.DicType;
import com.mz.auth.entity.DicTypeData;
import com.mz.auth.query.BaseQuery;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DicMapper {
    /**
     * 查询所有试卷难度等级
     * @return
     */
    @Select("select * from t_dictype_data where typeid=1")
    List<DicTypeData> findLevels();

    /**
     * 查询总的类型数据条数
     * @param baseQuery
     * @return
     */
    @Select("select count(*) from t_dictype_data")
    Long queryTotal(BaseQuery baseQuery);

    /**
     * 查询当前页的数据
     * @param baseQuery
     * @return
     */
    List<DicTypeData> queryData(BaseQuery baseQuery);

    /**
     * 查询所有数据字典
     * @return
     */
    @Select("select * from t_dictype")
    List<DicType> queryDicType();

    /**
     * 根据数据字典id查询其信息
     * @param id
     * @return
     */
    @Select("select * from t_dictype where id=#{id}")
    DicType queryDicTypeInfoById(Long id);

    /**
     * 新增数据字典
     * @param dicType
     */
    @Insert("insert into t_dictype(sn, info) values (#{sn},#{info})")
    void saveDicType(DicType dicType);

    /**
     * 修改数据字典
     * @param dicType
     */
    @Update("update t_dictype set sn=#{sn}, info=#{info} where id = #{id}")
    void editSaveDicType(DicType dicType);
}
